import Vue from "vue";
import Router from "vue-router";
import Home from "@/views/Home.vue";

Vue.use(Router);

export const constantRouterMap = [
  {
    path: "/",
    name: "home",
    navbaritem: "主页",
    component: Home
  },
  {
    path: "/myworkflow",
    name: "myworkflow",
    navbaritem: "我的申请",
    component: () => import("@/views/myworkflow.vue")
  },
  {
    path: "/daiban",
    name: "daiban",
    navbaritem: "我的待办",
    component: () => import("@/views/daiban.vue")
  },
  {
    path: "/lastfinishflow",
    name: "lastfinishflow",
    navbaritem: "最近完成单据",
    component: () => import("@/views/mylastfinishflow.vue")
  },
  {
    path: "/changepass",
    name: "changepass",
    navbaritem: "修改账户信息",
    component: () => import("@/views/changepass.vue")
  }
];

export default new Router({
  routes: constantRouterMap
});

export const asyncRouterMap = [
  {
    path: "/adminaccount",
    name: "adminaccount",
    navbaritem: "管理员账户管理",
    meta: {
      roles: ["manager"]
    },
    component: () => import("@/views/adminaccount.vue")
  },
  {
    path: "/flowmanage",
    name: "flowmanage",
    navbaritem: "审批流程管理",
    meta: {
      roles: ["manager", "sbumanager"]
    },
    component: () => import("@/views/flowmanage.vue")
  },
  {
    path: "/taizhang",
    name: "taizhang",
    navbaritem: "台账信息查询",
    meta: {
      roles: ["manager", "user", "sbumanager"]
    },
    component: () => import("@/views/taizhang.vue")
  },
  {
    path: "/application",
    name: "application",
    navbaritem: "流程申请单",
    meta: {
      roles: ["user", "manager", "sbumanager"]
    },
    component: () => import("@/views/application.vue"),
    children: [
      {
        path: "companyapplication",
        name: "companyapplication",
        navbaritem: "公司信息申请单",
        meta: {
          roles: ["manager", "user", "sbumanager"]
        },
        component: () => import("@/views/companyapplication.vue")
      },
      {
        path: "accountapplication",
        name: "accountapplication",
        navbaritem: "VPN账户申请单",
        meta: {
          roles: ["manager", "user", "sbumanager"]
        },
        component: () => import("@/views/accountapplication.vue")
      },
      {
        path: "macapplication",
        name: "macapplication",
        navbaritem: "Mac地址绑定申请单",
        meta: {
          roles: ["manager", "user", "sbumanager"]
        },
        component: () => import("@/views/macapplication.vue")
      }
    ]
  },
  {
    path: "/adminoperation",
    name: "adminoperation",
    navbaritem: "管理员操作",
    meta: {
      roles: ["manager", "sbumanager"]
    },
    component: () => import("@/views/adminoperation.vue"),
    children: [
      {
        path: "dealinglist",
        name: "dealinglist",
        navbaritem: "待处理信息",
        meta: {
          roles: ["manager", "sbumanager"]
        },
        component: () => import("@/views/dealinglist.vue")
      },
      {
        path: "dealingxml",
        name: "dealingxml",
        navbaritem: "管理员处理",
        meta: {
          roles: ["manager"]
        },
        component: () => import("@/views/dealingxml.vue")
      }
    ]
  },
  {
    path: "*",
    redirect: "/",
    hidden: true
  }
];
